import { getToken } from '@/utils/auth'
import request from '@/utils/request'

export function getProduct(data) { // 查询产品数据
  return request({
    url: '/product/product/getProduct',
    method: 'post',
    data
  })
}

export function getNoReport(data) { // 显示无报告产品
  var url = '/product/product/getNoReport'
  return request({
    url: url,
    method: 'post',
    data
  })
}

export function selectProductState() { // 查找产品类型
  var url = '/product/rules/selectProductState'
  return request({
    url: url,
    method: 'get'
  })
}

export function selectRulesName(data) { // 查找规则名称
  var url = '/product/rules/selectRulesName'
  return request({
    url: url,
    method: 'post',
    data
  })
}

export function SubmitReport(data) { // 提交产品报告
  var url = '/product/product/SubmitReport'
  return request({
    url: url,
    method: 'post',
    data: {
      products: data,
      requestID: getToken().substring(1)
    }
  })
}
export function saveCategory(param) { // 添加
  return request({
    url: '/product/product/insertproduct',
    method: 'post',
    params: {
      productState: param.productState, // 产品类型
      workID: parseInt(param.workID), // 工人号
      rulesname1: param.rulesname1,
      rulesname2: param.rulesname2,
      rulesname3: param.rulesname3,
      rulesname4: param.rulesname4,
      rulesdescrite1: param.rulesdecrite1, // 规则描述1
      rulesdescrite2: param.rulesdecrite2, // 规则描述2
      rulesdescrite3: param.rulesdecrite3, // 规则描述1
      rulesdescrite4: param.rulesdecrite4 // 规则描述1
    }
  })
}

export function query(data) { // 查询数据
  return request({
    url: '/product/product/getProduct2',
    method: 'post',
    data
  })
}
